package com.main.ok.cobbar;

import org.springframework.jdbc.core.JdbcTemplate;

import com.main.ok.common.CommonCallback;
import com.main.ok.common.CommonUtils;
import com.main.ok.common.RunSqlTool;

public class TestInsertTable {

    public static void main(String[] args) {

        CommonUtils.runTimeStatistics("cont", new CommonCallback() {
            @Override
            public void biz() {
                JdbcTemplate template = RunSqlTool.getJdbcTemplate();
                // String sql =
                // "insert into msg_his(id,taobaoId,name,upd_time) values(%s,%s,'jack',now())";
                String sql = "insert into msg_his (   id,   gmt_created,   gmt_modified,   memo,   receive_id,   content,   template_id,   type,   status,   app_id,   app_channel,   message_id,   uid_list   )   values   (   %s,   now(),   now(),   \"ssssssssss\",   1111122,   \"111111\",   1,   1,   1,   \"ssss\",   1,   11111,   11111   );   ";
                for (int i = 0; i < 2000; i++) {
                    String realSql = String.format(sql, i);
                    System.out.println(realSql);
                    template.execute(realSql);
                    try {
                        Thread.sleep(100);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            }
        });

        // tb1 --single table
        // CommonUtils.runTimeStatistics("tb1", new CommonCallback() {
        // @Override
        // public void biz() {
        // JdbcTemplate template = RunSqlTool.getJdbcTemplate();
        // String sql = "insert into tb1(id,gmt) values(%s,now()); ";
        // for (int i = 0; i < 2000; i++) {
        // String runTimeSql = String.format(sql, i);
        // template.execute(runTimeSql);
        // }
        // }
        // });

        // tb2 --use share table

        // CommonUtils.runTimeStatistics("tb2", new CommonCallback() {
        // @Override
        // public void biz() {
        // // TODO Auto-generated method stub
        // JdbcTemplate template = RunSqlTool.getJdbcTemplate();
        // String sql = "insert into tb2(id,gmt) values(%s,now()); ";
        // for (int i = 0; i < 2000; i++) {
        // String runTimeSql = String.format(sql, i);
        // template.execute(runTimeSql);
        // }
        // }
        // });

    }
}
